import java.util.Arrays;

public class ArrayEXercise {

    public static String myToString(int[] array) {

        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];
            if (i < array.length - 1){
                ret += ",";
            }else {
                ;
            }

/*            if(i != array.length - 1) {
                ret += ",";
            }*/

        }
        ret += "]";
        return ret;

    }
    public static void main(String[] args) {
/*        //1.数组转字符串
        //借助工具类
        int[] arr = {1,2,3,4,5};

        *//*String newArr = Arrays.toString(arr);
        System.out.println(newArr);*//*

        System.out.println(Arrays.toString(arr));*/

        int[] array = {1, 2, 3, 4, 5, 6};
        System.out.println(myToString(array));

        //数组拷贝
        int[] copy = new int[array.length];
        for (int i = 0;i < array.length;i++) {
            copy[i] = array[i];
        }
        System.out.println(Arrays.toString(copy));



















    }

}
